﻿using System;
using System.Net;

namespace WebServer.Service.BLL
{
    /// <summary>
    /// 网站总服务器类
    /// </summary>
    public class WebServer
    {
        #region "字段"

        /// <summary>
        /// 承载asp.net运行的程序域
        /// </summary>
        private WebHost webhost;

        #endregion

        #region "公共方法"

        /// <summary>
        /// 构造函数，传入监听的Url前缀进行监听
        /// </summary>
        /// <param name="physicalPath">网站的文件目录</param>
        /// <param name="listenPrefix">监听的前缀</param>
        public WebServer(String physicalPath, String[] listenPrefix)
        {
            webhost = WebHostManager.CreateWebHost(physicalPath);
            webhost.Initial(listenPrefix);
        }

        /// <summary>
        /// 启动服务器监听请求
        /// </summary>
        public void Start()
        {
            webhost.Start();
        }

        #endregion
    }
}
